package com.at.bigdata.spark.core.test

import java.io.ObjectInputStream
import java.net.ServerSocket

/**
 *
 * @author cdhuangchao3
 * @date 2023/3/18 10:29 AM
 */
object Executor {

  def bb(): Unit = {
    val server = new ServerSocket(9999)
    println("服务器启动9999，等待接收数据")

    val client = server.accept()
    val in = client.getInputStream

    val inputStream = new ObjectInputStream(in)
    val task = inputStream.readObject().asInstanceOf[Task]
    println("接收到客户发送的数据"+task.compute())
    inputStream.close()
    in.close()
    client.close()
    server.close()
  }

  def aa() = {
    val server = new ServerSocket(9999)
    println("服务器启动，等待接收数据")

    val client = server.accept()
    val in = client.getInputStream

    val inputStream = new ObjectInputStream(in)
    val task = inputStream.readObject().asInstanceOf[Task]
    println("接收到客户发送的数据"+task.compute())
    inputStream.close()
    in.close()
    client.close()
    server.close()
  }

  def main(args: Array[String]): Unit = {
//    aa()
    bb()
  }

}
